{# Twitter Bootstrap Sliding pagination control implementation #}

{% if style is not defined %}
    {% set style = 'pagination' %}
{% endif %}

{% if prev_label is not defined %}
    {% set prev_label = '<' %}
    {#% set prev_label = 'paginator.previousPageText' | trans({}, 'admin_interface') %#}
{% endif %}
{% if next_label is not defined %}
    {% set next_label = '>' %}
    {#% set next_label = 'paginator.nextPageText' | trans({}, 'admin_interface') %#}
{% endif %}
{% if first_label is not defined %}
    {% set first_label = '<<' %}
    {#% set first_label = 'paginator.firstPageText' | trans({}, 'admin_interface') %#}
{% endif %}
{% if last_label is not defined %}
    {% set last_label = '>>' %}
    {#% set last_label = 'paginator.lastPageText' | trans({}, 'admin_interface') %#}
{% endif %}


{#% if pageCount > 1 %#}
    {% if style == 'pagination' %}
        {% set orientation_class = '' %}
        {% if alignment is defined %}
            {% if alignment == 'center' %}
                {% set orientation_class = ' pagination-centered' %}
            {% elseif alignment == 'right' %}
                {% set orientation_class = ' pagination-right' %}
            {% endif %}
        {% endif %}

        <div class="pagination{{ orientation_class }} text-center">
            <ul>
                <li><span>
                {% set cou = ((totalCount % 10 == 1) and (totalCount % 100 != 11)) ? 0
                    : (((totalCount % 10 >= 2) and (totalCount % 10 <= 4) and
                    ((totalCount % 100 < 10) or (totalCount % 100 >= 20))) ? 1 : 2) %}
                {{ totalCount ~ ' ' }}
                {% transchoice totalCount with {'%cou%':cou} from "admin_interface" %}
                    paginator.results
                {% endtranschoice %}
                {% if totalCount > 0 %}
                    {% set cou2 = ((pageCount % 10 == 1) and (pageCount % 100 != 11)) ? 0 :
                        (((pageCount % 10 >= 2) and (pageCount % 10 <= 4) and
                        ((pageCount % 100 < 10) or (pageCount % 100 >= 20))) ? 1 : 2) %}
                    {{ pageCount ~ ' ' }}
                    {% transchoice pageCount with {'%cou2%':cou2} from "admin_interface" %}
                        paginator.items
                    {% endtranschoice %}
                {% endif %}
                </span></li>
                
            {% if totalCount != '0' %}
                
            {% if first is defined and current != first %}
                <li><a href="{{ path(route, query|merge({(pageParameterName): first})) }}">{{ first_label|raw }}</a></li>
            {% endif %}

            {% if previous is defined %}
                <li><a href="{{ path(route, query|merge({(pageParameterName): previous})) }}">{{ prev_label|raw }}</a></li>
            {% endif %}

            {% for page in pagesInRange %}
                {% if page != current %}
                    <li><a href="{{ path(route, query|merge({(pageParameterName): page})) }}">{{ page }}</a></li>
                {% else %}
                    <li class="active"><span>{{ page }}</span></li>
                {% endif %}
            {% endfor %}

            {% if next is defined %}
                <li><a href="{{ path(route, query|merge({(pageParameterName): next})) }}">{{ next_label|raw }}</a></li>
            {% endif %}

            {% if last is defined and current != last %}
                <li><a href="{{ path(route, query|merge({(pageParameterName): last})) }}">{{ last_label|raw }}</a></li>
            {% endif %}
            
            {% endif %}
            
            </ul>
        </div>
    {% else %}
        {% if aligned is not defined %}
            {% set aligned = false %}
        {% endif %}
        <ul class="pager">
            {% if previous is defined %}
                <li{% if aligned %} class="previous"{% endif %}><a href="{{ path(route, query|merge({(pageParameterName): previous})) }}">{{ prev_label|raw }}</a></li>
            {% else %}
                <li class="disabled{% if aligned %} previous{% endif %}"><span>{{ prev_label|raw }}</span></li>
            {% endif %}
            {% if next is defined %}
                <li{% if aligned %} class="next"{% endif %}><a href="{{ path(route, query|merge({(pageParameterName): next})) }}">{{ next_label|raw }}</a></li>
            {% else %}
                <li class="disabled{% if aligned %} next{% endif %}"><span>{{ next_label|raw }}</span></li>
            {% endif %}
        </ul>
    {% endif %}
{#% endif %#}
